package com.fa4j.system.account.controller;

import com.fa4j.system.account.api.AccountClient;
import com.fa4j.system.account.convert.AccountConverter;
import com.fa4j.system.account.dto.AccountDTO;
import com.fa4j.system.account.model.Account;
import com.fa4j.system.account.repository.AccountRepository;
import io.swagger.v3.oas.annotations.Hidden;
import io.swagger.v3.oas.annotations.Operation;
import lombok.RequiredArgsConstructor;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;

import java.util.Collection;
import java.util.List;

@Hidden
@RestController
@RequestMapping("/system/account")
@RequiredArgsConstructor
public class AccountResource implements AccountClient {

    private final AccountRepository accountRepository;
    private final AccountConverter accountConverter;

    /**
     * 根据 id 查询账号信息
     *
     * @param accountIds 账号 ID 集合
     * @return 账号列表
     */
    @Override
    @Operation(summary = "根据 id 查询账号信息", description = "根据 id 查询账号信息")
    public List<AccountDTO> queryAccountsByIds(Collection<Long> accountIds) {
        List<Account> accounts = accountRepository.queryByIds(accountIds);
        return accountConverter.toDtoList(accounts);
    }
}
